import config.ApplicationConfigurator;
import factory.GUIFactory;

/**
 * 客户端演示代码
 */
public class AbstractFactoryDemo {
    public static void main(String[] args) {
        System.out.println("抽象工厂模式演示 - 跨平台UI组件库\n");
        
        // 演示1: 手动指定平台
        System.out.println("演示1: Windows平台");
        GUIFactory windowsFactory = ApplicationConfigurator.createFactory("Windows");
        Application windowsApp = new Application(windowsFactory);
        runApplication(windowsApp);
        
        // 演示2: 手动指定另一个平台
        System.out.println("演示2: Mac平台");
        GUIFactory macFactory = ApplicationConfigurator.createFactory("Mac");
        Application macApp = new Application(macFactory);
        runApplication(macApp);
        
        // 演示3: 自动检测平台
        System.out.println("演示3: 自动检测平台");
        GUIFactory autoFactory = ApplicationConfigurator.createFactoryBySystem();
        Application autoApp = new Application(autoFactory);
        runApplication(autoApp);
    }
    
    private static void runApplication(Application app) {
        app.createUI();
        app.render();
        app.interact();
        app.renderAfterInteraction();
        System.out.println("=" .repeat(50) + "\n");
    }
}